package com.stars.empoly.activity

import android.os.Bundle
import android.text.Html
import android.util.Log
import android.webkit.WebView
import com.hwangjr.rxbus.RxBus
import com.qmuiteam.qmui.widget.webview.QMUIWebViewClient
import com.stars.empoly.base.MBActivity
import com.stars.empoly.databinding.ActivityDetailsBinding
import com.stars.empoly.utils.WebViewUtils
import com.stars.empoly.vmodel.TechDetailsVModel

/**
 * 服务详情
 *on 2022/10/10
 */
class TechDetailsActivity : MBActivity<TechDetailsVModel, ActivityDetailsBinding>(){


    override fun init(savedInstanceState: Bundle?) {
        super.init(savedInstanceState)
        //初始化webview
        binding.webView.webViewClient = object : QMUIWebViewClient(true, false) {
            override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
                Log.e("-shy-", "url=: " + url)

                return false

            }


        }


        val settings = binding.webView.settings
        settings.javaScriptEnabled = true
        settings.domStorageEnabled = true
        settings.setSupportMultipleWindows(true)
        settings.javaScriptCanOpenWindowsAutomatically = true


        vm.id=intent.extras?.getString("id")
        vm.getInfo()
        vm.bean.observe(this) {

            binding.tvExplain.text= Html.fromHtml(it.explains)

            binding.tvNeed.text= Html.fromHtml(it.notice)


            if (!it.details.isNullOrEmpty()) {
                binding.webView.loadDataWithBaseURL(
                    null,
                    WebViewUtils.getHtmlData2(it.details),
                    "text/html",
                    "utf-8",
                    null
                )

            }
        }

    }
    override fun vmClass(): Class<TechDetailsVModel> {
        return TechDetailsVModel::class.java
    }
    override fun binding(): ActivityDetailsBinding {
        return ActivityDetailsBinding.inflate(layoutInflater)
    }

    override fun title(): String? {
        return "服务详情"
    }
}
